/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.EnvMontorBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class EnvMontorDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(EnvMontorDAO.class);
/*  23 */   private dbConnector dbcon = null;
/*  24 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*  25 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*     */ 
/*     */   private void dbConInit() {
/*  28 */     if (this.dbcon == null)
/*  29 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  33 */     if (this.dbcon != null)
/*  34 */       this.dbcon.closeAll();
/*  35 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getEnvMontorList(Map condition)
/*     */   {
/*  40 */     ListContentsBFO bfo = new ListContentsBFO();
/*  41 */     int start = Integer.parseInt(condition.get("start").toString());
/*  42 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  43 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  44 */     ResultSet rs = null;
/*  45 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  48 */       dbConInit();
/*  49 */       String strSQL = " select count(id) from envmontor where btscode = '" + strBtscode + "' ";
/*  50 */       log.info(strSQL);
/*  51 */       rs = this.dbcon.execQuery(strSQL);
/*  52 */       if (rs.next()) {
/*  53 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  55 */       strSQL = " select * from envmontor where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  56 */       log.info(strSQL);
/*  57 */       rs = this.dbcon.execQuery(strSQL);
/*  58 */       while (rs.next()) {
/*  59 */         EnvMontorBO bo = new EnvMontorBO();
/*  60 */         bo.setId(rs.getString("id"));
/*  61 */         bo.setBtscode(rs.getString("btscode"));
/*  62 */         bo.setBtsname(rs.getString("btsname"));
/*  63 */         bo.setType(rs.getString("type"));
/*  64 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  65 */         bo.setMonobj(rs.getString("monobj"));
/*  66 */         bo.setTransType(rs.getString("transType"));
/*  67 */         bo.setTransPort(rs.getString("transPort"));
/*  68 */         bo.setOpentime(rs.getDate("registtime"));
/*  69 */         bo.setMaintenance(rs.getString("maintenance"));
/*  70 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  71 */         bo.setMemo(rs.getString("memo"));
/*  72 */         bo.setMonWorkSta(rs.getString("monWorkSta"));
/*  73 */         list.add(bo);
/*     */       }
/*  75 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  78 */       e.printStackTrace();
/*  79 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  82 */       dbConClose();
/*     */     }
/*  84 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveEnvMontorBO(EnvMontorBO bo)
/*     */   {
/*  89 */     log.info("添加--动环监控---开始");
/*  90 */     boolean flag = true;
/*     */     try
/*     */     {
/*  93 */       dbConInit();
/*  94 */       StringBuffer sqlBuf = new StringBuffer();
/*  95 */       sqlBuf.append(" insert into envmontor (btscode, btsname, type, manufacturer,");
/*  96 */       sqlBuf.append(" monobj, transType, transPort, registtime, maintenance,");
/*  97 */       sqlBuf.append(" refreshtime, memo, monWorkSta ) values ( ");
/*  98 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/*  99 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 100 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 101 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 102 */       sqlBuf.append(" '" + bo.getMonobj() + "' ,");
/* 103 */       sqlBuf.append(" '" + bo.getTransType() + "' ,");
/* 104 */       sqlBuf.append(" '" + bo.getTransPort() + "' ,");
/* 105 */       sqlBuf.append(" '" + this.open.format(bo.getOpentime()) + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 107 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getMonWorkSta() + "' )");
/* 110 */       log.info(sqlBuf.toString());
/* 111 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 115 */       flag = false;
/* 116 */       e.printStackTrace();
/* 117 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 120 */       dbConClose();
/*     */     }
/* 122 */     log.info("添加--动环监控---结束");
/* 123 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateEnvMontorBO(EnvMontorBO bo)
/*     */   {
/* 128 */     log.info("修改--动环监控---开始");
/* 129 */     boolean flag = true;
/*     */     try
/*     */     {
/* 132 */       dbConInit();
/* 133 */       StringBuffer sqlBuf = new StringBuffer();
/* 134 */       sqlBuf.append(" update  envmontor set ");
/* 135 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 136 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 137 */       sqlBuf.append(" monobj = '" + bo.getMonobj() + "' ,");
/* 138 */       sqlBuf.append(" transType = '" + bo.getTransType() + "' ,");
/* 139 */       sqlBuf.append(" transPort = '" + bo.getTransPort() + "' ,");
/* 140 */       sqlBuf.append(" registtime = '" + this.open.format(bo.getOpentime()) + "' ,");
/* 141 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 142 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 143 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 144 */       sqlBuf.append(" monWorkSta = '" + bo.getMonWorkSta() + "' ");
/* 145 */       sqlBuf.append(" where id = '" + bo.getId() + "'");
/* 146 */       log.info(sqlBuf.toString());
/* 147 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 151 */       flag = false;
/* 152 */       e.printStackTrace();
/* 153 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 156 */       dbConClose();
/*     */     }
/* 158 */     log.info("修改--动环监控---结束");
/* 159 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteEnvMontorBO(String strID)
/*     */   {
/* 164 */     log.info("删除--动环监控---开始");
/* 165 */     boolean flag = true;
/*     */     try
/*     */     {
/* 168 */       dbConInit();
/* 169 */       StringBuffer sqlBuf = new StringBuffer();
/* 170 */       sqlBuf.append(" delete from  envmontor  ");
/* 171 */       sqlBuf.append(" where id = '" + strID + "'");
/* 172 */       log.info(sqlBuf.toString());
/* 173 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 177 */       flag = false;
/* 178 */       e.printStackTrace();
/* 179 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 182 */       dbConClose();
/*     */     }
/* 184 */     log.info("删除--动环监控---结束");
/* 185 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getEnvMontorByBtsName(Map condition)
/*     */   {
/* 190 */     ListContentsBFO bfo = new ListContentsBFO();
/* 191 */     int start = Integer.parseInt(condition.get("start").toString());
/* 192 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 193 */     String strBtsName = condition.get("btsName").toString();
/* 194 */     ResultSet rs = null;
/* 195 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 198 */       dbConInit();
/* 199 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 200 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 202 */       String strSQL = " select count(id) from envmontor where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 203 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 204 */       log.info(strSQL);
/* 205 */       rs = this.dbcon.execQuery(strSQL);
/* 206 */       if (rs.next()) {
/* 207 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 209 */       strSQL = " select * from envmontor where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%') ";
/* 210 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 211 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 212 */       log.info(strSQL);
/* 213 */       rs = this.dbcon.execQuery(strSQL);
/* 214 */       while (rs.next()) {
/* 215 */         EnvMontorBO bo = new EnvMontorBO();
/* 216 */         bo.setId(rs.getString("id"));
/* 217 */         bo.setBtscode(rs.getString("btscode"));
/* 218 */         bo.setBtsname(rs.getString("btsname"));
/* 219 */         bo.setType(rs.getString("type"));
/* 220 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 221 */         bo.setMonobj(rs.getString("monobj"));
/* 222 */         bo.setTransType(rs.getString("transType"));
/* 223 */         bo.setTransPort(rs.getString("transPort"));
/* 224 */         bo.setOpentime(rs.getDate("registtime"));
/* 225 */         bo.setMaintenance(rs.getString("maintenance"));
/* 226 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 227 */         bo.setMemo(rs.getString("memo"));
/* 228 */         bo.setMonWorkSta(rs.getString("monWorkSta"));
/* 229 */         list.add(bo);
/*     */       }
/* 231 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 234 */       e.printStackTrace();
/* 235 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 238 */       dbConClose();
/*     */     }
/* 240 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 246 */     ResultSet rs = null;
/* 247 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 250 */       dbConInit();
/* 251 */       String strSQL = " select * from envmontor where btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ";
/* 252 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 253 */       log.info(strSQL);
/* 254 */       rs = this.dbcon.execQuery(strSQL);
/* 255 */       while (rs.next()) {
/* 256 */         EnvMontorBO bo = new EnvMontorBO();
/* 257 */         bo.setId(rs.getString("id"));
/* 258 */         bo.setBtscode(rs.getString("btscode"));
/* 259 */         bo.setBtsname(rs.getString("btsname"));
/* 260 */         bo.setType(rs.getString("type"));
/* 261 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 262 */         bo.setMonobj(rs.getString("monobj"));
/* 263 */         bo.setTransType(rs.getString("transType"));
/* 264 */         bo.setTransPort(rs.getString("transPort"));
/* 265 */         bo.setOpentime(rs.getDate("registtime"));
/* 266 */         bo.setMaintenance(rs.getString("maintenance"));
/* 267 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 268 */         bo.setMemo(rs.getString("memo"));
/* 269 */         bo.setMonWorkSta(rs.getString("monWorkSta"));
/* 270 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 274 */       e.printStackTrace();
/* 275 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 278 */       dbConClose();
/*     */     }
/* 280 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.EnvMontorDAO
 * JD-Core Version:    0.6.2
 */